cuttlefish: Remove fetch_cvd usage from acloud fetch_cvd was deprecated and deleted in 2023. The last readily available build of fetch cvd was recently purged and all acloud creates now fail due to its absence. To mitigate this - migrate all fetching to use the cvd binary. cvd is part of the Cloud Android Host image so it no longer needs to be fetched. Bug: 402627490 Test: m acloud; acloud-dev create Change-Id: I1ad4099888971fe071c7a8315eac811893815eb2 
diff --git a/create/avd_spec.py b/create/avd_spec.py index a84672d..d9458ef 100644 --- a/create/avd_spec.py +++ b/create/avd_spec.py 
@@ -158,7 +158,6 @@  self._webrtc_device_id = None  self._connect_hostname = None  self._fetch_cvd_wrapper = None - self._fetch_cvd_version = None  self._enable_fetch_local_caching = None  self._mix_system_dlkm_into_vendor_ramdisk = None   @@ -423,7 +422,6 @@  self._webrtc_device_id = args.webrtc_device_id  self._connect_hostname = args.connect_hostname or self._cfg.connect_hostname  self._fetch_cvd_wrapper = args.fetch_cvd_wrapper - self._fetch_cvd_version = self._GetFetchCVDVersion(args)  self._enable_fetch_local_caching = args.enable_fetch_local_caching  self._mix_system_dlkm_into_vendor_ramdisk = (  args.mix_system_dlkm_into_vendor_ramdisk) @@ -443,21 +441,6 @@  constants.BUILD_BRANCH: args.trusty_branch,  constants.BUILD_TARGET: args.trusty_build_target}   - def _GetFetchCVDVersion(self, args): - """Get the fetch_cvd version. - - Acloud will get the LKGB of fetch_cvd if no version specified. - - Args: - args: Namespace object from argparse.parse_args. - - Returns: - The build id of fetch_cvd. - """ - if args.fetch_cvd_build_id: - return args.fetch_cvd_build_id - return constants.LKGB -  @staticmethod  def _GetFlavorFromString(flavor_string):  """Get flavor name from flavor string. @@ -1000,11 +983,6 @@  return self._enable_fetch_local_caching    @property - def fetch_cvd_version(self): - """Return fetch_cvd_version.""" - return self._fetch_cvd_version - - @property  def num(self):  """Return num of instances."""  return self._num_of_instances 
diff --git a/create/avd_spec_test.py b/create/avd_spec_test.py index 33807cf..8b1927e 100644 --- a/create/avd_spec_test.py +++ b/create/avd_spec_test.py 
@@ -573,15 +573,6 @@  self.mock_config.connect_hostname = False  self.assertTrue(self.AvdSpec.connect_hostname)   - # Verify fetch_cvd_version - self.args.fetch_cvd_build_id = None - self.AvdSpec._ProcessMiscArgs(self.args) - self.assertEqual(self.AvdSpec.fetch_cvd_version, "LKGB") - - self.args.fetch_cvd_build_id = "23456" - self.AvdSpec._ProcessMiscArgs(self.args) - self.assertEqual(self.AvdSpec.fetch_cvd_version, "23456") -  self.args.trusty_branch = "trusty_branch"  self.args.trusty_build_id = "trusty_build_id"  self.args.trusty_build_target = "trusty_build_target" 
diff --git a/create/create_args.py b/create/create_args.py index bb42d25..26d0565 100644 --- a/create/create_args.py +++ b/create/create_args.py 
@@ -324,7 +324,7 @@  type=str,  dest="fetch_cvd_build_id",  required=False, - help="'cuttlefish only' Build id of fetch_cvd, e.g. 2145099, P2804227") + help="Deprecated - any values input through this param are ignored")  # TODO(146314062): Remove --multi-stage-launch after infra don't use this  # args.  parser.add_argument( 
diff --git a/internal/lib/android_build_client.py b/internal/lib/android_build_client.py index 4960bd0..273c3ff 100644 --- a/internal/lib/android_build_client.py +++ b/internal/lib/android_build_client.py 
@@ -64,14 +64,6 @@  ONE_RESULT = 1  BUILD_SUCCESSFUL = True  LATEST = "latest" - # FETCH_CVD variables. - FETCHER_NAME = "fetch_cvd" - FETCHER_BUILD_TARGET = "aosp_cf_x86_64_phone-trunk_staging-userdebug" - FETCHER_BUILD_TARGET_ARM = "aosp_cf_arm64_only_phone-trunk_staging-userdebug" - # TODO(b/297085994): cvd fetch is migrating from AOSP to github artifacts, so - # temporary returning hardcoded values instead of LKGB - FETCHER_BUILD_ID = 11559438 - FETCHER_BUILD_ID_ARM = 11559085  MAX_RETRY = 3  RETRY_SLEEP_SECS = 3   @@ -117,53 +109,6 @@  logger.error("Downloading artifact failed: %s", str(e))  raise errors.DriverError(str(e))   - def DownloadFetchcvd( - self, - local_dest, - fetch_cvd_version, - is_arm_version=False): - """Get fetch_cvd from Android Build. - - Args: - local_dest: A local path where the artifact should be stored. - e.g. "/tmp/fetch_cvd" - fetch_cvd_version: String of fetch_cvd version. - is_arm_version: is ARM version fetch_cvd. - """ - if fetch_cvd_version == constants.LKGB: - fetch_cvd_version = self.GetFetcherVersion(is_arm_version) - fetch_cvd_build_target = ( - self.FETCHER_BUILD_TARGET_ARM if is_arm_version - else self.FETCHER_BUILD_TARGET) - try: - utils.RetryExceptionType( - exception_types=(ssl.SSLError, errors.DriverError), - max_retries=self.MAX_RETRY, - functor=self.DownloadArtifact, - sleep_multiplier=self.RETRY_SLEEP_SECS, - retry_backoff_factor=utils.DEFAULT_RETRY_BACKOFF_FACTOR, - build_target=fetch_cvd_build_target, - build_id=fetch_cvd_version, - resource_id=self.FETCHER_NAME, - local_dest=local_dest, - attempt_id=self.LATEST) - except Exception: - logger.debug("Download fetch_cvd with build id: %s", - constants.FETCH_CVD_SECOND_VERSION) - utils.RetryExceptionType( - exception_types=(ssl.SSLError, errors.DriverError), - max_retries=self.MAX_RETRY, - functor=self.DownloadArtifact, - sleep_multiplier=self.RETRY_SLEEP_SECS, - retry_backoff_factor=utils.DEFAULT_RETRY_BACKOFF_FACTOR, - build_target=fetch_cvd_build_target, - build_id=constants.FETCH_CVD_SECOND_VERSION, - resource_id=self.FETCHER_NAME, - local_dest=local_dest, - attempt_id=self.LATEST) - fetch_cvd_stat = os.stat(local_dest) - os.chmod(local_dest, fetch_cvd_stat.st_mode | stat.S_IEXEC) -  @staticmethod  def ProcessBuild(build_info, ignore_artifact=False):  """Create a Cuttlefish fetch_cvd build string. 
diff --git a/internal/lib/cvd_compute_client_multi_stage.py b/internal/lib/cvd_compute_client_multi_stage.py index c6ba1b9..6ecd054 100644 --- a/internal/lib/cvd_compute_client_multi_stage.py +++ b/internal/lib/cvd_compute_client_multi_stage.py 
@@ -55,7 +55,6 @@  logger = logging.getLogger(__name__)    _DEFAULT_WEBRTC_DEVICE_ID = "cvd-1" -_FETCHER_NAME = "fetch_cvd"  _TRUST_REMOTE_INSTANCE_COMMAND = (  f"\"sudo cp -p ~/{constants.WEBRTC_CERTS_PATH}/{constants.SSL_CA_NAME}.pem "  f"{constants.SSL_TRUST_CA_DIR}/{constants.SSL_CA_NAME}.crt;" @@ -303,25 +302,6 @@  self._execution_time[constants.TIME_GCE] = time.time() - timestart  return ip   - @utils.TimeExecute(function_description="Uploading build fetcher to instance") - def UpdateFetchCvd(self, fetch_cvd_version): - """Download fetch_cvd from the Build API, and upload it to a remote instance. - - The version of fetch_cvd to use is retrieved from the configuration file. Once fetch_cvd - is on the instance, future commands can use it to download relevant Cuttlefish files from - the Build API on the instance itself. - - Args: - fetch_cvd_version: String. The build id of fetch_cvd. - """ - self.SetStage(constants.STAGE_ARTIFACT) - download_dir = tempfile.mkdtemp() - download_target = os.path.join(download_dir, _FETCHER_NAME) - self._build_api.DownloadFetchcvd(download_target, fetch_cvd_version) - self._ssh.ScpPushFile(src_file=download_target, dst_file=_FETCHER_NAME) - os.remove(download_target) - os.rmdir(download_dir) -  @utils.TimeExecute(function_description="Downloading build on instance")  def FetchBuild(self, default_build_info, system_build_info,  kernel_build_info, boot_build_info, bootloader_build_info, @@ -341,15 +321,16 @@  Returns:  List of string args for fetch_cvd.  """ + self.SetStage(constants.STAGE_ARTIFACT)  timestart = time.time() - fetch_cvd_args = ["-credential_source=gce"] + cmd = list(constants.CMD_CVD_FETCH) + ["-credential_source=gce"]  fetch_cvd_build_args = self._build_api.GetFetchBuildArgs(  default_build_info, system_build_info, kernel_build_info,  boot_build_info, bootloader_build_info, android_efi_loader_build_info,  ota_build_info, host_package_build_info) - fetch_cvd_args.extend(fetch_cvd_build_args) + cmd.extend(fetch_cvd_build_args)   - self._ssh.Run("./fetch_cvd " + " ".join(fetch_cvd_args), + self._ssh.Run(" ".join(cmd),  timeout=constants.DEFAULT_SSH_TIMEOUT)  self._execution_time[constants.TIME_ARTIFACT] = time.time() - timestart   
diff --git a/public/actions/remote_host_cf_device_factory_test.py b/public/actions/remote_host_cf_device_factory_test.py index 29a3bbc..77bbaef 100644 --- a/public/actions/remote_host_cf_device_factory_test.py +++ b/public/actions/remote_host_cf_device_factory_test.py 
@@ -46,7 +46,6 @@  mock_cfg = mock.Mock(spec=[],  ssh_private_key_path="/mock/id_rsa",  extra_args_ssh_tunnel="extra args", - fetch_cvd_version="123456",  creds_cache_file="credential",  service_account_json_private_key_path="/mock/key")  return mock.Mock(spec=[], @@ -76,7 +75,6 @@  fetch_cvd_wrapper=None,  base_instance_num=None,  num_avds_per_instance=None, - fetch_cvd_version="123456",  openwrt=True,  cfg=mock_cfg)   
diff --git a/public/actions/remote_instance_cf_device_factory.py b/public/actions/remote_instance_cf_device_factory.py index 1fbab05..7f569cb 100644 --- a/public/actions/remote_instance_cf_device_factory.py +++ b/public/actions/remote_instance_cf_device_factory.py 
@@ -112,7 +112,6 @@  avd_spec.local_image_dir),  self._cvd_host_package_artifact)  elif avd_spec.image_source == constants.IMAGE_SRC_REMOTE: - self._compute_client.UpdateFetchCvd(avd_spec.fetch_cvd_version)  self._compute_client.FetchBuild(  avd_spec.remote_image,  avd_spec.system_build_info, 
diff --git a/public/actions/remote_instance_cf_device_factory_test.py b/public/actions/remote_instance_cf_device_factory_test.py index a658a12..f0cbad7 100644 --- a/public/actions/remote_instance_cf_device_factory_test.py +++ b/public/actions/remote_instance_cf_device_factory_test.py 
@@ -43,7 +43,6 @@  self.Patch(android_build_client.AndroidBuildClient, "InitResourceHandle")  self.Patch(cvd_compute_client_multi_stage.CvdComputeClient, "InitResourceHandle")  self.Patch(cvd_compute_client_multi_stage.CvdComputeClient, "LaunchCvd") - self.Patch(cvd_compute_client_multi_stage.CvdComputeClient, "UpdateFetchCvd")  self.Patch(cvd_compute_client_multi_stage.CvdComputeClient, "FetchBuild")  self.Patch(list_instances, "GetInstancesFromInstanceNames", return_value=mock.MagicMock())  self.Patch(list_instances, "ChooseOneRemoteInstance", return_value=mock.MagicMock()) @@ -111,7 +110,6 @@  factory_remote_img._ProcessArtifacts()    compute_client = factory_remote_img.GetComputeClient() - compute_client.UpdateFetchCvd.assert_called_once()  compute_client.FetchBuild.assert_called_once()    # pylint: disable=protected-access 
diff --git a/public/config.py b/public/config.py index 3548b7c..23dd6a4 100755 --- a/public/config.py +++ b/public/config.py 
@@ -246,9 +246,6 @@  self.instance_name_pattern = (  usr_cfg.instance_name_pattern or  internal_cfg.default_usr_cfg.instance_name_pattern) - self.fetch_cvd_version = ( - usr_cfg.fetch_cvd_version or - internal_cfg.default_usr_cfg.fetch_cvd_version)  if usr_cfg.HasField("enable_multi_stage") is not None:  self.enable_multi_stage = usr_cfg.enable_multi_stage  elif internal_cfg.default_usr_cfg.HasField("enable_multi_stage"): 
diff --git a/public/data/default.config b/public/data/default.config index a1540ff..be7313e 100644 --- a/public/data/default.config +++ b/public/data/default.config 
@@ -18,7 +18,6 @@  network: "default"  extra_data_disk_size_gb: 0  instance_name_pattern: "ins-{uuid}-{build_id}-{build_target}" - fetch_cvd_version: "9123511"    metadata_variable {  key: "camera_front"